package com.wangzifan.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wangzifan.entity.Course;
import com.wangzifan.entity.PageBean;
import com.wangzifan.entity.Sclass;
import com.wangzifan.mapper.SclassMapper;
import com.wangzifan.service.SclassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SclassServiceImpl implements SclassService {
    @Autowired
    private SclassMapper sclassMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize) {
        //1. 设置分页参数
        PageHelper.startPage(page,pageSize);
        List<Sclass> sclasses = sclassMapper.querySclass();
        Page<Sclass> p = (Page<Sclass>) sclasses;

        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
        return pageBean;
    }

    @Override
    public Sclass querySclassById(Integer id) {
        return sclassMapper.querySclassById(id);
    }

    @Override
    public void deleteSclass(List<Integer> ids) {
        sclassMapper.deleteSclass(ids);
    }

    @Override
    public void addSclass(Sclass sclass) {
        sclassMapper.addSclass(sclass);
    }

    @Override
    public void updateSclass(Sclass sclass) {
        sclassMapper.updateSclass(sclass);
    }
}
